﻿using System;
using Microsoft.Xna.Framework;

namespace Serious
{
    public static class Vector3Ext
    {
        public static Vector3 Map (Func<Single, Single> f, Vector3 v)
        {
            v.X = f(v.X);
            v.Y = f(v.Y);
            v.Z = f(v.Z);
            return v;
        }
        
        public static Vector2 AsXY (this Vector3 v)
        {
            return new Vector2(v.X, v.Y);
        }
        public static Vector2 AsYZ (this Vector3 v)
        {
            return new Vector2(v.Y, v.Z);
        }
        public static Vector2 AsZX (this Vector3 v)
        {
            return new Vector2(v.Y, v.X);
        }
        public static Vector2 AsXZ (this Vector3 v)
        {
            return new Vector2(v.X, v.Z);
        }
        public static Vector2 AsZY (this Vector3 v)
        {
            return new Vector2(v.Z, v.Y);
        }
        public static Vector2 AsYX (this Vector3 v)
        {
            return new Vector2(v.Y, v.X);
        }
        
        public static Vector3 Floor(Vector3 v)
        {
            return new Vector3((Single)Math.Floor(v.X), (Single)Math.Floor(v.Y), (Single)Math.Floor(v.Z));
        }
        public static Vector3 Ceiling(Vector3 v)
        {
            return new Vector3((Single)Math.Ceiling(v.X), (Single)Math.Ceiling(v.Y), (Single)Math.Ceiling(v.Z));
        }
        public static Vector3 Round(Vector3 v)
        {
            return new Vector3((Single)Math.Round(v.X), (Single)Math.Round(v.Y), (Single)Math.Round(v.Z));
        }
        public static Vector3 Abs(Vector3 v)
        {
            return new Vector3(Math.Abs(v.X), Math.Abs(v.Y), Math.Abs(v.Z));
        }
    }
}
